#include "helper/stl_helper.h"

#include "svm.h"

void print_null(const char *s) {}

void libsvm_parse_parameter(struct svm_parameter& param, boost::program_options::variables_map& vm)
{
  void (*print_func)(const char*) = NULL;	// default printing to stdout
  // default values
  param.svm_type = VMIF(vm, "svm_s", int, C_SVC);
  param.kernel_type = VMIF(vm, "svm_t", int, RBF);
  param.degree = VMIF(vm, "svm_d", int, 3);
  param.gamma = VMIF(vm, "svm_g", double, 0);	// 1/num_features
  param.coef0 = VMIF(vm, "svm_r", double, 0);
  param.nu = VMIF(vm, "svm_n", double, 0.5);
  param.cache_size = VMIF(vm, "svm_m", double, 100);
  param.C = VMIF(vm, "svm_c", double, 1);
  param.eps = VMIF(vm, "svm_e", double, 1e-3);
  param.p = VMIF(vm, "svm_p", double, 0.1);
  param.shrinking = VMIF(vm, "svm_h", int, 1);
  param.probability = VMIF(vm, "svm_b", int, 0);
  if (vm.count("svm_q")) print_func = &print_null;
  param.nr_weight = 0;
  param.weight_label = NULL;
  param.weight = NULL;

  svm_set_print_string_function(print_func);
  /*
		switch(argv[i-1][1])
		{
			case 'q':
				print_func = &print_null;
				i--;
				break;
			case 'v':
				cross_validation = 1;
				nr_fold = atoi(argv[i]);
				if(nr_fold < 2)
				{
					fprintf(stderr,"n-fold cross validation: n must >= 2\n");
					exit_with_help();
				}
				break;
			case 'w':
				++param.nr_weight;
				param.weight_label = (int *)realloc(param.weight_label,sizeof(int)*param.nr_weight);
				param.weight = (double *)realloc(param.weight,sizeof(double)*param.nr_weight);
				param.weight_label[param.nr_weight-1] = atoi(&argv[i-1][2]);
				param.weight[param.nr_weight-1] = atof(argv[i]);
				break;
			default:
				fprintf(stderr,"Unknown option: -%c\n", argv[i-1][1]);
				exit_with_help();
		}
  */
}
